package com.youdoneed.community.forumConfig.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.youdoneed.community.forumConfig.dao.ForumconfigurationMapper;
import com.youdoneed.community.forumConfig.entity.Forumconfiguration;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * 猿圈配置表服务接口
 * @author lid
 * @date 2017.6.19
 */
@Service
public class ForumconfigurationService {
	
	private final Logger logger = LoggerFactory.getLogger(ForumconfigurationService.class);
	
	@Autowired
	ForumconfigurationMapper forumconfigurationMapper;
	
	/**
	 * 获取猿圈配置
	 * @author lid
	 * @return Forumconfiguration
	 * @date 2017
	 */
	public Forumconfiguration getConfiguration(){
		try {
			logger.info("getConfiguration");
			return forumconfigurationMapper.getConfiguration();
		} catch (Exception e) {
			logger.info("获取猿圈配置异常！"+ e.getMessage());
			return null;
		}
		
	}

	/**
	 * 修改猿圈配置
	 * @author xz
	 * @return Forumconfiguration
	 * @date 2017
	 */
	@Transactional
	public int updataConfiguration(Forumconfiguration record){
		record.setUpdateDate(new Date());
		try {
			return forumconfigurationMapper.updateByPrimaryKey(record);
		} catch (Exception e) {
			logger.error("修改配置异常："+e);
			return 0;
		}
	}
}
